from .celery import app
from django.db.models import F
import time
from rest_framework.response import Response

def compare_time(over_time):
    s = str(over_time).split('.')[0]
    struct_time = time.strptime(s,'%Y-%m-%d %H:%M:%S')
    timec = time.mktime(struct_time)
    # print(timec<time.time())
    if timec<time.time():
        print(777)
        return True


@app.task
def vip_update():
    from user import models
    user_list = models.User.objects.all()
    for user in user_list:
        if user.over_time:
            if compare_time(user.over_time):
                user.is_vip = False
                user.save()
    return True